import { defineStore } from 'pinia';

// @ts-nocheck
interface LogsType {
  id: number;
  userName: String;
  refType: number;
  refId: number;
  refName: String;
}
interface MembersType {
  isOneself: Boolean;
  phone: String;
  company: String;
  email: String;
  auditStatus: number;
  name: String;
}
interface projectData {
  coverUrl: String;
  createDate: String;
  isAsterisk: Boolean;
  name: String;
  description: String;
  createUserName: String;
  projectId: number | String;
  publishStatus: number;
  role: number;
  logs: Array<LogsType>;
  members: Array<MembersType>;
} 
interface StyleInfo {
  background: String;
}
export const useProjectStore = defineStore('project', {
  state: () => ({
    id: 0,
    delId: 0,
    moduleList: {
      projectId: 0,
      parentId: 0,
      sort: [],
    }, 
    loginModeShow:false,
    seachType:false,//搜索栏状态
    homeShow:true,
    searchInfo:[],//搜索内容 
    templateType: 0,
    tabvalue: 1,
    uploadModel: false, 
    drawerShow: false,
    visitExhibitsInfoShow: false,
    descriptionExhibitsInfoShow: false,
    templateUnitType: false,
    correlationModuleId: 0,
    exhibitsDescription: '',
    exhibitsName: '',
    getUnitSlectInfo: {
      id: 0,
      level: 0,
      number: 0,
      parentId: 0,
      children:[],
      remarks: '',
      sort: 0,
      text: '',
      type: 1,
      value: '',
    },
    glanceOver: false,
    linkType: false,
    isCollectBtn: true,
    childModel: {
      id: 0,
      level: 0,
      number: 0,
      parentId: 0,
      remarks: '',
      sort: 0,
      text: '',
      type: 1,
      value: '',
    },
    parentId: 0, 
    projectRole: 3,  
    styleInfo: {  
      logo: '', 
      moduleList: [],
      id: 0, //模板id
      projectId: 0, //模板id
      colorType: 1, //颜色id
      themeColor: '#CFBDA8', //主题色
      auxiliaryColor: '#fff', //辅助色
      background: '#FAF9F7', //背景色 
      shmentColor: '#D2AD77', //点缀色 
      fontColor: '#333', //字体色
      fontFamily: 'SourceHanSerifCN', //标题字体
      textFamily: 'SourceHanSerifCN', //正文字体
      sizeType: 1, //字体类型
      contentSize: '19px', //正文字号
      titleSize: '34px', //标题字号
      mintitleSize: '18px', //小标题字号
      styleType: 0, //风格样式
      banners: [], //首页轮播图
    },
    projectInfo: {
      coverUrl: '371947843936325',
      createDate: '2023/02/01 09:24:22',
      createUserName: '',
      description: '',
      isAsterisk: true,
      logs: [],
      members: [],
      name: '恋山游',
      projectId: 0,
      publishStatus: 1, 
      role: 3,
    },
    correlationExhibits: [],
    BiographyMenuType: 0,
    scrollBox: 0, 
    isUnitTem6: -1,  
    research7Type: false,
    template5Type: false,
    isBack: false,
    tmplate2ChildShow: {
      id: 0, 
      level: 0,
      number: 0,
      parentId: 0,
      remarks: '',
      sort: 0,
      text: '',
      type: 1,
      value: '',
      children: [],
    },
  }), 
  getters: {}, 
  actions: {     
    setloginModeShow(e:boolean){
      this.loginModeShow=e
    },
    sethomeShow(e:boolean){
      this.homeShow=e 
    },
    setseachType(){ 
      
      this.seachType=!this.seachType
      
    },
    settmplate2ChildShow(e: any) {
      if (e) {
        this.tmplate2ChildShow = e;
      } else {
        this.tmplate2ChildShow = {
          id: 0,
          level: 0,
          number: 0,
          parentId: 0,
          remarks: '',
          sort: 0,
          text: '',
          type: 1,
          value: '',
          children: [],
        };
      }
    },
    settemplate5Type() {
      this.template5Type = !this.template5Type;
    },
    setresearch7Type(e: boolean) {
      this.research7Type = e;
    },
    setBiographyMenuType(e: number) {
      this.BiographyMenuType = e;
    },
    setIsUnitTem6(data) { 
      this.isUnitTem6 = data;
    },
    setScrollBox(data: number) {
      this.scrollBox = data;
    },
    setCorrelationModuleId(data: number | string) {
      this.correlationModuleId = data;
    },
    setGetUnitSlectInfo(data?: any) { 
      if (data) {
        this.getUnitSlectInfo = data;
      } else {
        this.getUnitSlectInfo = {
          id: 0,
          level: 0,
          number: 0,
          parentId: 0,
          children:[],
          remarks: '',
          sort: 0,
          text: '',
          type: 1,
          value: '',
        };
      }
    },
    setvisitExhibitsInfoShow(data: boolean) {
      this.visitExhibitsInfoShow = data;
    },
    setDescriptionExhibitsInfoShow(data: boolean) {
      this.descriptionExhibitsInfoShow = data;
    },
    setUploadModel() {
      this.uploadModel = !this.uploadModel;
    },
    setdrawerShow(data: boolean) {
      this.drawerShow = data;
    }, 
    setLinkType(data: boolean) {
      this.linkType = data; 
    }, 
    settextInfoShow(data: boolean) {
      this.textInfoShow = data;
    },
    setSearchInfo(str:string){
      if(this.searchInfo.length>10){ 
        this.searchInfo[0]=str
      }else{
        this.searchInfo.unshift(str)
      }
       
    }, 
    setSearchClear(){ 
      this.searchInfo=[]
    },
    settemplateUnitType(e: boolean) {
      this.templateUnitType = e;
    }, 
    setTeplateType(data: number) {
      this.templateType = data;
    },
    setstyleInfo(data: any) { 
      this.styleInfo.logo = data.logo; 
      this.styleInfo.moduleList = data.moduleList; 
      this.styleInfo.id = data.id;  
      this.styleInfo.projectId = data.projectId;
      this.styleInfo.themeColor = data.themeColor ? data.themeColor : '#CFBDA8';
      this.styleInfo.auxiliaryColor = data.auxiliaryColor ? data.auxiliaryColor : '#fff';
      this.styleInfo.background = data.background ? data.background : '#FAF9F7';
      this.styleInfo.shmentColor = data.shmentColor ? data.shmentColor : '#D2AD77';
      this.styleInfo.fontColor = data.fontColor ? data.fontColor : '#333';
      this.styleInfo.fontFamily = data.fontFamily ? data.fontFamily : 'SourceHanSerifCN';
      this.styleInfo.textFamily = data.textFamily ? data.textFamily : 'SourceHanSerifCN';
      this.styleInfo.sizeType = data.sizeType ? data.sizeType : 1;
      this.styleInfo.contentSize = '16px';
      this.styleInfo.titleSize = '34px';
      this.styleInfo.mintitleSize = '18px';
      this.styleInfo.styleType = data.styleType ? data.styleType : 1;
      this.styleInfo.banners = data.banners ? data.banners : [];
      this.styleInfo.colorType = data.colorType ? data.colorType : 1;
    },
    setColorType(data: number) {
      this.styleInfo.colorType = data;
    },
    setchildModel(styleInfo: any) {
      this.childModel = styleInfo;
    },
    setglanceOver() {
      this.glanceOver = !this.glanceOver;
    },
    setColor(data: any) {
      this.styleInfo.themeColor = data.themeColor;
      this.styleInfo.auxiliaryColor = data.auxiliaryColor;
      this.styleInfo.background = data.background;
      this.styleInfo.shmentColor = data.shmentColor;
      this.styleInfo.fontColor = data.fontColor;
    },
    setFontsize(data: any) {
      this.styleInfo.contentSize = data.contentSize;
      this.styleInfo.titleSize = data.titleSize;
      this.styleInfo.mintitleSize = data.mintitleSize;
    },
    setFontFamily(data: any, type: number) {
      if (type === 1) {
        this.styleInfo.fontFamily = data;
      } else {
        this.styleInfo.textFamily = data;
      }
    },
    setBanner(data: any) {
      this.styleInfo.banners = data;
    },
    setLogo(data: any) {
      this.styleInfo.logo = data;
    },
    setStypeType(data: any) {
      this.styleInfo.styleType = data.id;
    },
    setProjectData(data: projectData) {
      this.projectInfo = data;
    },
    setProjectRole(data: number) {
      this.projectRole = data;
    },
  },
  persist: true,
});
